package com.gnerv.pabu.sso.controller;

import com.gnerv.pabu.sso.entity.Result;
import com.gnerv.pabu.sso.entity.SsoLoginDTO;
import com.gnerv.pabu.sso.service.SsoService;
import com.gnerv.pabu.sso.utils.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/api/sso")
public class SsoController {

    @Resource
    private SsoService ssoService;

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public Result login(@RequestBody String loginInfo) {
        boolean b = ssoService.checkAccount();
        String token = ssoService.createToken();
        return Result.response().data("PabuAccessToken", token);
    }

    @RequestMapping(value = "/verify", method = RequestMethod.POST)
    public Result verify(HttpServletRequest request) {
        boolean verify = JwtUtils.verify("");
        return Result.response().data("verifyToken", verify);
    }



}
